package com.ptu.spzx.manager.controller;

import com.ptu.spzx.manager.service.SysMenuService;
import com.ptu.spzx.model.entity.system.SysMenu;
import com.ptu.spzx.model.vo.common.Result;
import com.ptu.spzx.model.vo.common.ResultCodeEnum;
import org.simpleframework.xml.Path;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(value = "/admin/system/sysMenu")
public class SysMenuController {
  @Autowired
  private SysMenuService sysMenuService;

  //菜单的删除
  @DeleteMapping("/removeById/{id}")
  public Result removeById(@PathVariable(value = "id") Long id){
      sysMenuService.removeById(id);
      return Result.build(null, ResultCodeEnum.SUCCESS);
  }
  //菜单的修改
  @PutMapping("/update")
  public Result update(@RequestBody SysMenu sysMenu){
      sysMenuService.update(sysMenu);
      return Result.build(null, ResultCodeEnum.SUCCESS);
  }

  //菜单的添加
  @PostMapping("/save")
  public Result save(@RequestBody SysMenu sysMenu){
      sysMenuService.save(sysMenu);
      return Result.build(null, ResultCodeEnum.SUCCESS);
  }

  //菜单列表
    @GetMapping("/findNodes")
    public Result findNodes(){
        List<SysMenu> list=sysMenuService.findNodes();
        return Result.build(list, ResultCodeEnum.SUCCESS);
    }
}
